﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Model
{
    [Table("sys_organization")]
    public class SysOrganization
    {
        [Key]
        [Column("org_id")]
        public long OrgId { get; set; }

        [Column("org_code")]
        [Required]
        [StringLength(50)]
        public string OrgCode { get; set; }

        [Column("org_name")]
        [Required]
        [StringLength(100)]
        public string OrgName { get; set; }

        [Column("org_short_name")]
        [StringLength(50)]
        public string? OrgShortName { get; set; }

        [Column("parent_org_id")]
        public long ParentOrgId { get; set; }

        [Column("org_level")]
        public int OrgLevel { get; set; }

        [Column("org_remark")]
        [StringLength(500)]
        public string? OrgRemark { get; set; }

        [Column("org_status")]
        [StringLength(10)]
        public string? OrgStatus { get; set; }

        // 确保这个属性有正确的忽略配置
        [NotMapped]  // 添加这个特性，明确表示不映射到数据库
        public List<SysOrganization> Children { get; set; } = new List<SysOrganization>();
    }

    public class SysOrganizationDTO
    {
        [Key]
        public long OrgId { get; set; }
        public string OrgCode { get; set; }
        public string OrgName { get; set; }
        public long ParentOrgId { get; set; }
        public int OrgLevel { get; set; }
    }
}